{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.core.interactiveshell import InteractiveShell\n",
    "InteractiveShell.ast_node_interactivity = \"all\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 吴恩达机器学习作业Python实现(一)：线性回归\n",
    "# https://blog.csdn.net/Cowry5/article/details/80174130"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 单变量实现线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 导入数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Population</th>\n",
       "      <th>Profit</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6.1101</td>\n",
       "      <td>17.5920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5.5277</td>\n",
       "      <td>9.1302</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8.5186</td>\n",
       "      <td>13.6620</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>7.0032</td>\n",
       "      <td>11.8540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.8598</td>\n",
       "      <td>6.8233</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Population   Profit\n",
       "0      6.1101  17.5920\n",
       "1      5.5277   9.1302\n",
       "2      8.5186  13.6620\n",
       "3      7.0032  11.8540\n",
       "4      5.8598   6.8233"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "path =  'ex1data1.txt'\n",
    "# names添加列名，header用指定的行来作为标题，若原无标题且指定标题则设为None\n",
    "data = pd.read_csv(path, header=None, names=['Population', 'Profit'])  \n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Population</th>\n",
       "      <th>Profit</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>97.000000</td>\n",
       "      <td>97.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>8.159800</td>\n",
       "      <td>5.839135</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>3.869884</td>\n",
       "      <td>5.510262</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>5.026900</td>\n",
       "      <td>-2.680700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>5.707700</td>\n",
       "      <td>1.986900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>6.589400</td>\n",
       "      <td>4.562300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>8.578100</td>\n",
       "      <td>7.046700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>22.203000</td>\n",
       "      <td>24.147000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Population     Profit\n",
       "count   97.000000  97.000000\n",
       "mean     8.159800   5.839135\n",
       "std      3.869884   5.510262\n",
       "min      5.026900  -2.680700\n",
       "25%      5.707700   1.986900\n",
       "50%      6.589400   4.562300\n",
       "75%      8.578100   7.046700\n",
       "max     22.203000  24.147000"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x182fa320>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAe4AAAE9CAYAAADNvYHXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3df5RcdZnn8c9T/SuBDiQkgYkJmJkJOhtdiNqLYquD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0l/PpW4AClgdDMiAoAf494OhYwASjIwbAIAEIeMGACBByLgBAEgQAjcAAAlC4AYAIEEI3AAAJAiBGwCABCFwAwCQIP8fcRohPLKfVdsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data.plot(kind='scatter', x='Population', y='Profit', figsize=(8,5))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   Ones  Population   Profit\n",
      "0     1      6.1101  17.5920\n",
      "1     1      5.5277   9.1302\n",
      "2     1      8.5186  13.6620\n",
      "3     1      7.0032  11.8540\n",
      "4     1      5.8598   6.8233\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# 让我们在训练集中添加一列，以便我们可以使用向量化的解决方案来计算代价和梯度。\n",
    "data.insert(0, 'Ones', 1)\n",
    "print(data.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "<class 'pandas.core.frame.DataFrame'>\n",
      "    Ones  Population\n",
      "0      1      6.1101\n",
      "1      1      5.5277\n",
      "2      1      8.5186\n",
      "3      1      7.0032\n",
      "4      1      5.8598\n",
      "..   ...         ...\n",
      "92     1      5.8707\n",
      "93     1      5.3054\n",
      "94     1      8.2934\n",
      "95     1     13.3940\n",
      "96     1      5.4369\n",
      "\n",
      "[97 rows x 2 columns]\n",
      "<class 'pandas.core.frame.DataFrame'>\n",
      "      Profit\n",
      "0   17.59200\n",
      "1    9.13020\n",
      "2   13.66200\n",
      "3   11.85400\n",
      "4    6.82330\n",
      "..       ...\n",
      "92   7.20290\n",
      "93   1.98690\n",
      "94   0.14454\n",
      "95   9.05510\n",
      "96   0.61705\n",
      "\n",
      "[97 rows x 1 columns]\n"
     ]
    }
   ],
   "source": [
    "# 取最后一列为 y，其余为 X\n",
    "cols = data.shape[1]  # 列数\n",
    "X = data.iloc[:,0:cols - 1]  # 取前cols-1列，即输入向量\n",
    "Y = data.iloc[:,cols - 1:cols]  # 取最后一列，即目标向量\n",
    "\n",
    "print(cols)\n",
    "print(type(X))\n",
    "print(X)\n",
    "print(type(Y))\n",
    "print(Y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "x = np.matrix(X.values) # 人口\n",
    "print(type(x))\n",
    "print(x)\n",
    "y = np.matrix(Y.values) # 利润\n",
    "print(type(y))\n",
    "print(y)\n",
    "theta = np.matrix([0,0])\n",
    "print(type(theta))\n",
    "print(theta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "首先，我们将创建一个以参数θ为特征函数的代价函数\n",
    "$$ J\\left( \\theta  \\right)=\\frac{1}{2m}\\sum\\limits_{i=1}^{m}{{{\\left( {{h}_{\\theta }}\\left( {{x}^{(i)}} \\right)-{{y}^{(i)}} \\right)}^{2}}} $$\n",
    "\n",
    "其中：$${{h}_{\\theta }}\\left( x \\right)={{\\theta }^{T}}X={{\\theta }_{0}}{{x}_{0}}+{{\\theta }_{1}}{{x}_{1}}+{{\\theta }_{2}}{{x}_{2}}+...+{{\\theta }_{n}}{{x}_{n}}$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((97, 2), (97, 1), (1, 2), (2, 1))"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.shape, y.shape, theta.shape, theta.T.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32.072733877455676"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "theta = np.matrix([0,0])\n",
    "\n",
    "# 代价函数\n",
    "def computeCost(x, y, theta):\n",
    "    inner = np.power(((x * theta.T) - y), 2)\n",
    "    return np.sum(inner) / (2 * len(x))\n",
    "# 计算初始代价函数的值 (theta初始值为0).\n",
    "c = computeCost(x, y, theta)  # # 32.072733877455676\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "x * theta.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(x * theta.T) - y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "inner = np.power(((x * theta.T) - y), 2)\n",
    "inner"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "194"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(2 * len(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32.072733877455676"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sum(inner) / (2 * len(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32.072733877455676"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "computeCost(x, y, theta) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## batch gradient decent（批量梯度下降）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$J\\left( \\theta  \\right)=\\frac{1}{2m}\\sum\\limits{i=1}^{m}{{{\\left( {{h}{\\theta }}\\left( {{x}^{(i)}} \\right)-{{y}^{(i)}} \\right)}^{2}}}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "其中：$${{h}_{\\theta }}\\left( x \\right)={{\\theta }^{T}}X={{\\theta }_{0}}{{x}_{0}}+{{\\theta }_{1}}{{x}_{1}}+{{\\theta }_{2}}{{x}_{2}}+...+{{\\theta }_{n}}{{x}_{n}}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "优化：$${{\\theta }_{j}}:={{\\theta }_{j}}-\\alpha \\frac{\\partial }{\\partial {{\\theta }_{j}}}J\\left( \\theta  \\right)$$\n",
    "\n",
    "$$\\theta_j:=\\theta_j-\\alpha\\frac{1}{m}\\sum^{m}_{i=1}(h_\\theta(x^{(i)}) - y^{(i)})x_j^{(i)}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用 vectorization同时更新所有的 θ，可以大大提高效率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "def gradientDescent(x, y, theta, alpha, epoch):\n",
    "    \"\"\"reuturn theta, cost\"\"\"\n",
    "    \n",
    "    temp = np.matrix(np.zeros(theta.shape))  # 初始化一个 θ 临时矩阵(1, 2)\n",
    "    parameters = int(theta.flatten().shape[1])  # 参数 θ的数量\n",
    "    cost = np.zeros(epoch)  # 初始化一个ndarray，包含每次epoch的cost\n",
    "    m = x.shape[0]  # 样本数量m\n",
    "    \n",
    "    for i in range(epoch):\n",
    "        # 利用向量化一步求解\n",
    "        temp =theta - (alpha / m) * (x * theta.T - y).T * x\n",
    "        \n",
    "        # 以下是不用Vectorization求解梯度下降\n",
    "        #         error = (X * theta.T) - y  # (97, 1)\n",
    "\n",
    "        #         for j in range(parameters):\n",
    "        #             term = np.multiply(error, X[:,j])  # (97, 1)\n",
    "        #             temp[0,j] = theta[0,j] - ((alpha / m) * np.sum(term))  # (1,1)\n",
    "\n",
    "        theta = temp\n",
    "        cost[i] = computeCost(x, y, theta)\n",
    "        \n",
    "    return theta, cost\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[-3.24140214,  1.1272942 ]])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "array([6.73719046, 5.93159357, 5.90115471, 5.89522859, 5.89009494,\n",
       "       5.88500416, 5.87993248, 5.87487909, 5.86984391, 5.86482687,\n",
       "       5.85982789, 5.85484692, 5.84988389, 5.84493874, 5.8400114 ,\n",
       "       5.83510181, 5.8302099 , 5.82533562, 5.82047889, 5.81563965,\n",
       "       5.81081784, 5.8060134 , 5.80122627, 5.79645638, 5.79170367,\n",
       "       5.78696808, 5.78224955, 5.77754801, 5.77286341, 5.76819568,\n",
       "       5.76354477, 5.75891061, 5.75429313, 5.7496923 , 5.74510803,\n",
       "       5.74054027, 5.73598897, 5.73145406, 5.72693549, 5.72243319,\n",
       "       5.71794711, 5.71347718, 5.70902336, 5.70458558, 5.70016379,\n",
       "       5.69575792, 5.69136792, 5.68699373, 5.6826353 , 5.67829257,\n",
       "       5.67396548, 5.66965398, 5.665358  , 5.6610775 , 5.65681242,\n",
       "       5.6525627 , 5.64832829, 5.64410913, 5.63990517, 5.63571635,\n",
       "       5.63154261, 5.62738391, 5.6232402 , 5.6191114 , 5.61499748,\n",
       "       5.61089837, 5.60681403, 5.60274441, 5.59868944, 5.59464907,\n",
       "       5.59062326, 5.58661195, 5.58261509, 5.57863263, 5.57466451,\n",
       "       5.57071068, 5.56677109, 5.5628457 , 5.55893444, 5.55503727,\n",
       "       5.55115414, 5.547285  , 5.54342979, 5.53958847, 5.53576098,\n",
       "       5.53194728, 5.52814732, 5.52436105, 5.52058841, 5.51682936,\n",
       "       5.51308385, 5.50935183, 5.50563326, 5.50192808, 5.49823624,\n",
       "       5.49455771, 5.49089242, 5.48724033, 5.4836014 , 5.47997558,\n",
       "       5.47636282, 5.47276307, 5.46917628, 5.46560242, 5.46204143,\n",
       "       5.45849326, 5.45495788, 5.45143522, 5.44792526, 5.44442794,\n",
       "       5.44094322, 5.43747105, 5.43401138, 5.43056418, 5.42712939,\n",
       "       5.42370698, 5.42029689, 5.41689909, 5.41351352, 5.41014015,\n",
       "       5.40677893, 5.40342982, 5.40009277, 5.39676774, 5.39345469,\n",
       "       5.39015357, 5.38686434, 5.38358696, 5.38032138, 5.37706756,\n",
       "       5.37382547, 5.37059505, 5.36737627, 5.36416908, 5.36097345,\n",
       "       5.35778933, 5.35461667, 5.35145544, 5.3483056 , 5.34516711,\n",
       "       5.34203991, 5.33892399, 5.33581928, 5.33272576, 5.32964339,\n",
       "       5.32657211, 5.3235119 , 5.32046271, 5.3174245 , 5.31439724,\n",
       "       5.31138088, 5.30837538, 5.30538071, 5.30239683, 5.2994237 ,\n",
       "       5.29646127, 5.29350951, 5.29056839, 5.28763786, 5.28471789,\n",
       "       5.28180843, 5.27890945, 5.27602092, 5.27314279, 5.27027503,\n",
       "       5.26741759, 5.26457045, 5.26173356, 5.2589069 , 5.25609041,\n",
       "       5.25328407, 5.25048783, 5.24770167, 5.24492555, 5.24215942,\n",
       "       5.23940326, 5.23665702, 5.23392068, 5.23119419, 5.22847752,\n",
       "       5.22577064, 5.22307351, 5.22038609, 5.21770835, 5.21504026,\n",
       "       5.21238178, 5.20973288, 5.20709351, 5.20446365, 5.20184327,\n",
       "       5.19923232, 5.19663078, 5.19403861, 5.19145577, 5.18888224,\n",
       "       5.18631798, 5.18376295, 5.18121713, 5.17868048, 5.17615296,\n",
       "       5.17363455, 5.17112521, 5.16862491, 5.16613361, 5.16365129,\n",
       "       5.16117791, 5.15871344, 5.15625784, 5.15381109, 5.15137315,\n",
       "       5.148944  , 5.14652359, 5.1441119 , 5.1417089 , 5.13931455,\n",
       "       5.13692883, 5.1345517 , 5.13218314, 5.1298231 , 5.12747157,\n",
       "       5.1251285 , 5.12279388, 5.12046766, 5.11814983, 5.11584034,\n",
       "       5.11353917, 5.11124629, 5.10896167, 5.10668527, 5.10441708,\n",
       "       5.10215706, 5.09990518, 5.0976614 , 5.09542571, 5.09319808,\n",
       "       5.09097846, 5.08876685, 5.08656319, 5.08436748, 5.08217967,\n",
       "       5.07999975, 5.07782768, 5.07566343, 5.07350697, 5.07135828,\n",
       "       5.06921734, 5.0670841 , 5.06495855, 5.06284065, 5.06073039,\n",
       "       5.05862772, 5.05653263, 5.05444508, 5.05236505, 5.05029252,\n",
       "       5.04822745, 5.04616982, 5.0441196 , 5.04207676, 5.04004129,\n",
       "       5.03801314, 5.0359923 , 5.03397874, 5.03197243, 5.02997335,\n",
       "       5.02798147, 5.02599676, 5.0240192 , 5.02204877, 5.02008543,\n",
       "       5.01812917, 5.01617995, 5.01423775, 5.01230255, 5.01037431,\n",
       "       5.00845303, 5.00653866, 5.00463119, 5.00273059, 5.00083684,\n",
       "       4.9989499 , 4.99706977, 4.9951964 , 4.99332979, 4.99146989,\n",
       "       4.9896167 , 4.98777018, 4.98593031, 4.98409707, 4.98227043,\n",
       "       4.98045038, 4.97863687, 4.9768299 , 4.97502944, 4.97323547,\n",
       "       4.97144795, 4.96966687, 4.96789221, 4.96612395, 4.96436205,\n",
       "       4.96260649, 4.96085726, 4.95911433, 4.95737768, 4.95564729,\n",
       "       4.95392312, 4.95220517, 4.95049341, 4.94878781, 4.94708835,\n",
       "       4.94539502, 4.94370778, 4.94202663, 4.94035152, 4.93868246,\n",
       "       4.9370194 , 4.93536233, 4.93371123, 4.93206608, 4.93042686,\n",
       "       4.92879354, 4.9271661 , 4.92554453, 4.92392879, 4.92231888,\n",
       "       4.92071476, 4.91911642, 4.91752384, 4.915937  , 4.91435587,\n",
       "       4.91278043, 4.91121067, 4.90964657, 4.9080881 , 4.90653524,\n",
       "       4.90498798, 4.90344629, 4.90191015, 4.90037954, 4.89885445,\n",
       "       4.89733485, 4.89582073, 4.89431206, 4.89280882, 4.891311  ,\n",
       "       4.88981857, 4.88833152, 4.88684982, 4.88537346, 4.88390242,\n",
       "       4.88243668, 4.88097622, 4.87952102, 4.87807106, 4.87662632,\n",
       "       4.87518678, 4.87375243, 4.87232325, 4.87089922, 4.86948031,\n",
       "       4.86806652, 4.86665782, 4.86525419, 4.86385562, 4.86246208,\n",
       "       4.86107357, 4.85969005, 4.85831152, 4.85693796, 4.85556934,\n",
       "       4.85420565, 4.85284687, 4.85149299, 4.85014399, 4.84879984,\n",
       "       4.84746054, 4.84612606, 4.84479638, 4.8434715 , 4.84215138,\n",
       "       4.84083603, 4.83952541, 4.83821951, 4.83691831, 4.83562181,\n",
       "       4.83432997, 4.83304278, 4.83176023, 4.83048231, 4.82920898,\n",
       "       4.82794024, 4.82667607, 4.82541645, 4.82416138, 4.82291082,\n",
       "       4.82166476, 4.8204232 , 4.8191861 , 4.81795347, 4.81672527,\n",
       "       4.81550149, 4.81428213, 4.81306715, 4.81185656, 4.81065032,\n",
       "       4.80944843, 4.80825086, 4.80705761, 4.80586866, 4.80468399,\n",
       "       4.80350359, 4.80232744, 4.80115553, 4.79998784, 4.79882435,\n",
       "       4.79766505, 4.79650993, 4.79535897, 4.79421216, 4.79306948,\n",
       "       4.79193091, 4.79079644, 4.78966606, 4.78853976, 4.7874175 ,\n",
       "       4.7862993 , 4.78518511, 4.78407495, 4.78296878, 4.78186659,\n",
       "       4.78076838, 4.77967412, 4.7785838 , 4.77749741, 4.77641493,\n",
       "       4.77533635, 4.77426166, 4.77319084, 4.77212387, 4.77106075,\n",
       "       4.77000146, 4.76894598, 4.7678943 , 4.76684642, 4.7658023 ,\n",
       "       4.76476195, 4.76372535, 4.76269247, 4.76166332, 4.76063788,\n",
       "       4.75961613, 4.75859806, 4.75758366, 4.75657291, 4.7555658 ,\n",
       "       4.75456232, 4.75356245, 4.75256619, 4.75157351, 4.75058441,\n",
       "       4.74959887, 4.74861688, 4.74763843, 4.7466635 , 4.74569209,\n",
       "       4.74472417, 4.74375974, 4.74279878, 4.74184129, 4.74088724,\n",
       "       4.73993663, 4.73898945, 4.73804567, 4.7371053 , 4.73616831,\n",
       "       4.7352347 , 4.73430445, 4.73337755, 4.73245399, 4.73153376,\n",
       "       4.73061684, 4.72970322, 4.7287929 , 4.72788585, 4.72698207,\n",
       "       4.72608155, 4.72518427, 4.72429022, 4.72339939, 4.72251177,\n",
       "       4.72162735, 4.72074611, 4.71986805, 4.71899315, 4.7181214 ,\n",
       "       4.71725279, 4.71638731, 4.71552495, 4.71466569, 4.71380953,\n",
       "       4.71295645, 4.71210645, 4.71125951, 4.71041561, 4.70957476,\n",
       "       4.70873694, 4.70790213, 4.70707033, 4.70624153, 4.70541571,\n",
       "       4.70459287, 4.70377299, 4.70295606, 4.70214208, 4.70133103,\n",
       "       4.7005229 , 4.69971768, 4.69891536, 4.69811593, 4.69731938,\n",
       "       4.6965257 , 4.69573487, 4.6949469 , 4.69416177, 4.69337946,\n",
       "       4.69259997, 4.69182329, 4.6910494 , 4.69027831, 4.68950999,\n",
       "       4.68874444, 4.68798164, 4.68722159, 4.68646428, 4.6857097 ,\n",
       "       4.68495784, 4.68420868, 4.68346223, 4.68271846, 4.68197737,\n",
       "       4.68123895, 4.68050319, 4.67977008, 4.67903961, 4.67831177,\n",
       "       4.67758656, 4.67686395, 4.67614395, 4.67542654, 4.67471172,\n",
       "       4.67399947, 4.67328979, 4.67258266, 4.67187808, 4.67117604,\n",
       "       4.67047652, 4.66977953, 4.66908504, 4.66839306, 4.66770357,\n",
       "       4.66701656, 4.66633203, 4.66564997, 4.66497036, 4.6642932 ,\n",
       "       4.66361847, 4.66294618, 4.66227631, 4.66160885, 4.6609438 ,\n",
       "       4.66028114, 4.65962087, 4.65896298, 4.65830745, 4.65765429,\n",
       "       4.65700348, 4.65635502, 4.65570889, 4.65506509, 4.6544236 ,\n",
       "       4.65378443, 4.65314756, 4.65251298, 4.65188069, 4.65125068,\n",
       "       4.65062293, 4.64999745, 4.64937422, 4.64875324, 4.64813449,\n",
       "       4.64751797, 4.64690367, 4.64629158, 4.6456817 , 4.64507402,\n",
       "       4.64446852, 4.64386521, 4.64326406, 4.64266509, 4.64206827,\n",
       "       4.6414736 , 4.64088107, 4.64029068, 4.63970241, 4.63911626,\n",
       "       4.63853223, 4.63795029, 4.63737046, 4.63679271, 4.63621704,\n",
       "       4.63564345, 4.63507192, 4.63450245, 4.63393503, 4.63336966,\n",
       "       4.63280632, 4.63224501, 4.63168573, 4.63112845, 4.63057319,\n",
       "       4.63001992, 4.62946865, 4.62891937, 4.62837206, 4.62782672,\n",
       "       4.62728335, 4.62674193, 4.62620247, 4.62566495, 4.62512936,\n",
       "       4.62459571, 4.62406397, 4.62353415, 4.62300624, 4.62248023,\n",
       "       4.62195612, 4.62143389, 4.62091355, 4.62039507, 4.61987847,\n",
       "       4.61936373, 4.61885084, 4.6183398 , 4.6178306 , 4.61732323,\n",
       "       4.61681769, 4.61631397, 4.61581207, 4.61531197, 4.61481368,\n",
       "       4.61431718, 4.61382246, 4.61332954, 4.61283838, 4.612349  ,\n",
       "       4.61186137, 4.61137551, 4.61089139, 4.61040902, 4.60992838,\n",
       "       4.60944948, 4.6089723 , 4.60849684, 4.6080231 , 4.60755106,\n",
       "       4.60708071, 4.60661207, 4.60614511, 4.60567983, 4.60521623,\n",
       "       4.6047543 , 4.60429404, 4.60383543, 4.60337847, 4.60292316,\n",
       "       4.60246949, 4.60201745, 4.60156704, 4.60111826, 4.60067109,\n",
       "       4.60022553, 4.59978157, 4.59933922, 4.59889846, 4.59845928,\n",
       "       4.59802169, 4.59758567, 4.59715123, 4.59671835, 4.59628702,\n",
       "       4.59585726, 4.59542904, 4.59500236, 4.59457722, 4.59415361,\n",
       "       4.59373152, 4.59331096, 4.59289191, 4.59247437, 4.59205834,\n",
       "       4.5916438 , 4.59123076, 4.5908192 , 4.59040913, 4.59000053,\n",
       "       4.58959341, 4.58918775, 4.58878355, 4.58838081, 4.58797952,\n",
       "       4.58757968, 4.58718127, 4.5867843 , 4.58638876, 4.58599465,\n",
       "       4.58560195, 4.58521067, 4.5848208 , 4.58443233, 4.58404526,\n",
       "       4.58365959, 4.58327531, 4.5828924 , 4.58251088, 4.58213074,\n",
       "       4.58175196, 4.58137454, 4.58099849, 4.58062379, 4.58025044,\n",
       "       4.57987844, 4.57950777, 4.57913844, 4.57877044, 4.57840377,\n",
       "       4.57803841, 4.57767437, 4.57731165, 4.57695023, 4.57659011,\n",
       "       4.57623129, 4.57587376, 4.57551752, 4.57516256, 4.57480888,\n",
       "       4.57445648, 4.57410534, 4.57375547, 4.57340686, 4.57305951,\n",
       "       4.5727134 , 4.57236854, 4.57202493, 4.57168255, 4.57134141,\n",
       "       4.57100149, 4.5706628 , 4.57032533, 4.56998908, 4.56965403,\n",
       "       4.56932019, 4.56898756, 4.56865612, 4.56832588, 4.56799682,\n",
       "       4.56766896, 4.56734227, 4.56701676, 4.56669242, 4.56636925,\n",
       "       4.56604724, 4.5657264 , 4.56540671, 4.56508817, 4.56477078,\n",
       "       4.56445453, 4.56413942, 4.56382544, 4.5635126 , 4.56320088,\n",
       "       4.56289029, 4.56258082, 4.56227246, 4.56196521, 4.56165906,\n",
       "       4.56135402, 4.56105008, 4.56074723, 4.56044548, 4.56014481,\n",
       "       4.55984522, 4.55954672, 4.55924929, 4.55895293, 4.55865763,\n",
       "       4.5583634 , 4.55807023, 4.55777812, 4.55748706, 4.55719705,\n",
       "       4.55690808, 4.55662015, 4.55633326, 4.5560474 , 4.55576258,\n",
       "       4.55547878, 4.555196  , 4.55491424, 4.55463349, 4.55435376,\n",
       "       4.55407503, 4.55379731, 4.55352058, 4.55324486, 4.55297012,\n",
       "       4.55269638, 4.55242362, 4.55215185, 4.55188105, 4.55161123,\n",
       "       4.55134239, 4.55107451, 4.55080759, 4.55054164, 4.55027664,\n",
       "       4.5500126 , 4.54974951, 4.54948737, 4.54922617, 4.54896591,\n",
       "       4.54870659, 4.5484482 , 4.54819075, 4.54793422, 4.54767862,\n",
       "       4.54742393, 4.54717017, 4.54691731, 4.54666537, 4.54641434,\n",
       "       4.54616421, 4.54591498, 4.54566665, 4.54541921, 4.54517267,\n",
       "       4.54492701, 4.54468224, 4.54443835, 4.54419534, 4.5439532 ,\n",
       "       4.54371194, 4.54347154, 4.54323201, 4.54299334, 4.54275554,\n",
       "       4.54251859, 4.54228249, 4.54204724, 4.54181284, 4.54157929,\n",
       "       4.54134657, 4.5411147 , 4.54088366, 4.54065345, 4.54042407,\n",
       "       4.54019552, 4.53996779, 4.53974088, 4.53951478, 4.53928951,\n",
       "       4.53906504, 4.53884138, 4.53861853, 4.53839648, 4.53817523,\n",
       "       4.53795478, 4.53773512, 4.53751625, 4.53729817, 4.53708088,\n",
       "       4.53686437, 4.53664864, 4.53643368, 4.5362195 , 4.5360061 ,\n",
       "       4.53579346, 4.53558158, 4.53537047, 4.53516012, 4.53495053,\n",
       "       4.53474169, 4.53453361, 4.53432627, 4.53411968, 4.53391384,\n",
       "       4.53370873, 4.53350437, 4.53330074, 4.53309784, 4.53289568,\n",
       "       4.53269424, 4.53249353, 4.53229355, 4.53209428, 4.53189573,\n",
       "       4.53169789, 4.53150077, 4.53130436, 4.53110866, 4.53091366,\n",
       "       4.53071936, 4.53052576, 4.53033286, 4.53014066, 4.52994915,\n",
       "       4.52975832, 4.52956819, 4.52937874, 4.52918997, 4.52900188,\n",
       "       4.52881447, 4.52862773, 4.52844167, 4.52825628, 4.52807155,\n",
       "       4.52788749, 4.52770409, 4.52752136, 4.52733928, 4.52715786,\n",
       "       4.52697709, 4.52679697, 4.5266175 , 4.52643868, 4.5262605 ,\n",
       "       4.52608297, 4.52590607, 4.52572981, 4.52555418, 4.52537919,\n",
       "       4.52520483, 4.52503109, 4.52485799, 4.5246855 , 4.52451364,\n",
       "       4.52434239, 4.52417177, 4.52400175, 4.52383235, 4.52366356,\n",
       "       4.52349538, 4.5233278 , 4.52316083, 4.52299446, 4.52282868,\n",
       "       4.52266351, 4.52249893, 4.52233494, 4.52217154, 4.52200874,\n",
       "       4.52184651, 4.52168488, 4.52152382, 4.52136335, 4.52120345,\n",
       "       4.52104413, 4.52088538, 4.5207272 , 4.5205696 , 4.52041256,\n",
       "       4.52025609, 4.52010018, 4.51994483, 4.51979004, 4.51963581,\n",
       "       4.51948214, 4.51932902, 4.51917645, 4.51902443, 4.51887295,\n",
       "       4.51872203, 4.51857164, 4.5184218 , 4.5182725 , 4.51812373,\n",
       "       4.51797551, 4.51782781, 4.51768065, 4.51753402, 4.51738791,\n",
       "       4.51724233, 4.51709728, 4.51695275, 4.51680874, 4.51666525,\n",
       "       4.51652227, 4.51637981, 4.51623786, 4.51609643, 4.5159555 ])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alpha = 0.01\n",
    "epoch = 1000\n",
    "theta = np.matrix([0,0])\n",
    "final_theta, cost = gradientDescent(x, y, theta, alpha, epoch)\n",
    "final_theta\n",
    "cost"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "alpha = 0.01\n",
    "epoch = 1000\n",
    "theta = np.matrix([0,0])\n",
    "temp = np.matrix(np.zeros(theta.shape))  # 初始化一个 θ 临时矩阵(1, 2)\n",
    "parameters = int(theta.flatten().shape[1])  # 参数 θ的数量\n",
    "cost = np.zeros(epoch)  # 初始化一个ndarray，包含每次epoch的cost\n",
    "m = x.shape[0]  # 样本数量m\n",
    "i = range(epoch)[0]\n",
    "temp =theta - (alpha / m) * (x * theta.T - y).T * x\n",
    "final_theta = temp\n",
    "final_theta\n",
    "_cost = computeCost(x, y, theta)\n",
    "_cost"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[0.06289175, 0.77000978]])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "6.73719043540304"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alpha = 0.01\n",
    "epoch = 1000\n",
    "theta = np.matrix([[0.05839135, 0.6532885 ]])\n",
    "temp = np.matrix(np.zeros(theta.shape))  # 初始化一个 θ 临时矩阵(1, 2)\n",
    "parameters = int(theta.flatten().shape[1])  # 参数 θ的数量\n",
    "cost = np.zeros(epoch)  # 初始化一个ndarray，包含每次epoch的cost\n",
    "m = x.shape[0]  # 样本数量m\n",
    "i = range(epoch)[0]\n",
    "temp =theta - (alpha / m) * (x * theta.T - y).T * x\n",
    "final_theta = temp\n",
    "final_theta\n",
    "_cost = computeCost(x, y, theta)\n",
    "_cost"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1a4ee208>]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x5f19e10>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x5ec4e48>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "Text(0.5, 0, 'Population')"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Profit')"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1.0, 'Predicted Profit vs. Population Size')"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEWCAYAAABhff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lP5/iJUmbUfwNwct5fqj3uJOIfOi/cRE5V0S+FJEcEXlfRA73km4NA271vnl0F5dz/w7vPe1E5AufnOt1vOUfisg4EflKRL4Xke7R/3hMOrHAb1Kel0+mD7BERDoCVwKdcXMxXCsi7b1VmwNPq2obYDtwQxl28ynQRVXb41Ilj1TVNcCTwCTvm8cnfu95AbjT298S4C6f1w5S1ROB4X7LjakwC/wmlVUVNyvUAmAtLidKN+A1Vd2lLvndTFxaYYB1qjrfe/wfb91wNQDeE5ElwAggZPpsEakF1FbVj7xFU3CTnRQrTtb1DdCkDOUwplSpmpbZGPDa+H0XFCe8C8I/f0nx873sryRVCfLeR4CJqvqGiJyGm02rIv7wfhdi/6cmwqzGb9LNx0B/EanmZTQcgGv/B2gkIid5jy/BNd+Am96uo/f4/CDbrQXkeo9952ndgZtSrwRV/R3Y6tN+fxnwkf96xkSDBX6TVtRNczcZ+Ao309GzqprjvbwcGCIi3+LmXH3CW3438JCIfIKrgQcyBnjFW+dXn+VvAgOKb+76vWcIMN7bXzvgHxU5NmPCZdk5jWHftHdveV0/jUlpVuM3xpg0YzV+Y4xJM1bjN8aYNGOB3xhj0owFfmOMSTMW+I0xJs1Y4DfGmDTz/wEiIdlGzNadPQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.linspace(data.Population.min(), data.Population.max(), 100)  # 横坐标\n",
    "f = final_theta[0, 0] + (final_theta[0, 1] * x)  # 纵坐标，利润\n",
    "# print(final_theta[0, 0])\n",
    "# print(final_theta[0, 1] * x)\n",
    "# print(f)\n",
    "fig, ax = plt.subplots(figsize=(6,4))\n",
    "ax.plot(x, f, 'r', label='Prediction')\n",
    "ax.scatter(data['Population'], data.Profit, label='Traning Data')\n",
    "ax.legend(loc=2)  # 2表示在左上角\n",
    "ax.set_xlabel('Population')\n",
    "ax.set_ylabel('Profit')\n",
    "ax.set_title('Predicted Profit vs. Population Size')\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x5f52128>]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "Text(0.5, 0, 'Iterations')"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Cost')"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1.0, 'Error vs. Training Epoch')"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAfEAAAEWCAYAAAB2c65HAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deZxWZf3/8dd7GHZQUNAUUFxw30BSMBdwwTTU8qupWe6ZWpraJn1LK7+V/mxxqTRTM5dMxRS3EHPJpVQGFEVxFwRFQUxWke3z++M649wMwzDDzD33nLnfz8fjPO45y9z35z4cHu+5rnOdcxQRmJmZWf5UlLoAMzMzWzsOcTMzs5xyiJuZmeWUQ9zMzCynHOJmZmY55RA3MzPLKYe4mTWapGGSXmzubfNA0gxJw0pdhxk4xM1WImmqpI8lLSiYflfquppC0l4F32WhpKj1/TZp7HtGxKMRsX1zb9tYkp6QtLjW97mzGJ9l1hpVlroAs1bokIj455o2klQZEcvWtKyx79HcIuJxoFv2ef2Bt4Aeq/tcSRXZ760oZl3N6LSIuL7URZiVglviZg0k6QRJT0r6raQPgZ+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MiF2yabOIqG6JL/x0I2kY6UlXQyNiZ+BZ0v2z1/Teq/NJwc/LgcpIz6XejfRkvC8CYxv1TcwMcIibtWXzge4F8w8Ap2ePlUXSVpK61vF76wL/jYhFkrYBhhSsW1r9+7U8BhyVnXfvDexNelhGnbJn068bEfcDZ5O64s2skXxO3Kzteh5YlnWLXw9cRurKnpgNLptNagXXNhY4TdLzwCukLvVqVwPPS5oY6VGq1e4EhgKTSE+8+35EvJf9EVCX7sAYSZ1Irfhz1u4rmpU3P8XMzMwsp9ydbmZmllMOcTMzs5xyiJuZmeWUQ9zMzCynHOJmZmY55RA3MzPLKYe4mZlZTv1/yqMJpLmzb8IAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 576x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots(figsize=(8,4))\n",
    "ax.plot(np.arange(epoch), cost, 'r')  # np.arange()返回等差数组\n",
    "ax.set_xlabel('Iterations')\n",
    "ax.set_ylabel('Cost')\n",
    "ax.set_title('Error vs. Training Epoch')\n",
    "plt.show()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
